<?php
/**
 * Created by PhpStorm.
 * User: s.utkin
 * Date: 09.01.2015
 * Time: 18:45
 */

namespace Pinenut\Queue;


use Pinenut\Queue;

class ProcessingQueue extends Queue {

	/**
	 * Тип уведомления
	 *
	 * @var int
	 */
	public $type;

	public static function fields()
	{
		return array_merge(
			parent::fields(),
			[
				'type' => self::INT,
			]
		);
	}

	public function beforeSave()
	{
		if ($this->isNew()) {
			$data = (array)$this->data;

			$existingFields = static::fields();
			foreach ($data as $key => $value) {
				if (!array_key_exists($key, $existingFields)) {
					continue;
				}

				$this->$key = $value;
			}
		}
	}
} 